package cn.autumnorange.user.entity;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

import java.util.ArrayList;
import java.util.Collection;

public class UserDetailImpl {
  private String username;
  private String password;
  private Collection<? extends GrantedAuthority> authorities;

  public UserDetailImpl() {}

  public void setUsername(String username) {
    this.username = username;
  }

  public void setPassword(String password) {
    this.password = password;
  }

  public Collection<? extends GrantedAuthority> getAuthorities() {
    SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority("ROLE_admin");

    ArrayList arrayList = new ArrayList<SimpleGrantedAuthority>();
    arrayList.add(simpleGrantedAuthority);
    return arrayList;
    //    return authorities;
  }

  public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
    this.authorities = authorities;
  }
  //  public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
  //    this.authorities = authorities;
  //  }

  //  public Collection<? extends GrantedAuthority> getAuthorities() {
  //    SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority("ROLE_admin");
  //
  //    ArrayList arrayList = new ArrayList<SimpleGrantedAuthority>();
  //    arrayList.add(simpleGrantedAuthority);
  //    return arrayList;
  //  }

  public String getPassword() {
    return "$2a$10$NOEHdEJIXfGXg3Hkjg88EOzR/0joUopUlkIpDPkmiah1bx4TMRwf.";
  }

  public String getUsername() {
    return "admin";
  }
}
